package com.zhl.study.util;

import lombok.extern.slf4j.Slf4j;

/**
 * @description 用户上下文信息
 * @Author: z156940l@outlook.com
 * @className UserUtils
 * @Date: 2023/4/28 9:38
 */
@Slf4j
public class UserUtils {

    private static final ThreadLocal<String> userLocal = new ThreadLocal<>();

    public static String getUserId() {
        return userLocal.get();
    }

    public static void setUserId(String userId) {
        userLocal.set(userId);
    }

    public static void clear() {
        userLocal.remove();
    }
}